'''
    Rockaby: a text annotation system
    Copyright 2010 Martin Paul Eve

    This file is part of Rockaby.

    Rockaby is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    Rockaby is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with Rockaby.  If not, see <http://www.gnu.org/licenses/>.

'''

from django.conf.urls.defaults import *
from rockaby import settings


# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    (r'^$', 'rockaby.views.homepage'),
    
    (r'^episodes/$', 'rockaby.views.episodeindex'),
    (r'^episodes/(?P<part_name>.+)/synopsis/episode_(?P<episode_id>\d+)/$', 'rockaby.views.episodesynopsis'),
    (r'^episodes/(?P<part_name>.+)/character_index/episode_(?P<episode_id>\d+)/$', 'rockaby.views.episodecharacters'),
    (r'^episodes/(?P<part_name>.+)/reference_notes/episode_(?P<episode_id>\d+)/$', 'rockaby.views.episodereference'),
    
    (r'^characters/$', 'rockaby.views.characterindex'),
    (r'^characters/(?P<item_name>.+)/$', 'rockaby.views.iteminfo', {'ref_or_char':'char'}),
    
    (r'^reference/$', 'rockaby.views.referenceindex'),
    (r'^reference/(?P<item_name>.+)/$', 'rockaby.views.iteminfo', {'ref_or_char':'ref'}),
    
    (r'^parts/(?P<part_name>.+)/$', 'rockaby.views.partinfo'),
    
    #(r'^media/(?P<path>.*\..+)$', 'django.views.static.serve',
    #    {'document_root': '/home/martin/workspace/rockaby/src/pynchon/media/'}),
    # Example:
    # (r'^pynchon/', include('rockaby.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
     (r'^admin/', include(admin.site.urls)),
)

if settings.DEBUG:
    from django.views.static import serve
    _media_url = settings.MEDIA_URL
    
    if _media_url.startswith('/'):
        _media_url = _media_url[1:]
        urlpatterns += patterns('',
                                (r'^%s(?P<path>.*)$' % _media_url,
                                 serve,
                                 {'document_root': settings.MEDIA_ROOT}))
        del(_media_url, serve)

